﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using Easydp.Models.Entities;
using Easydp.Models;
using System.Data;

namespace Easydp.Controllers
{
    [DataObject()]
   public class TransferTicketController
    {
        TransferTicketManager manager = new TransferTicketManager();
        [DataObjectMethod(DataObjectMethodType.Select)]
        public DataSet GetData(string sql)
        {
            if (string.IsNullOrEmpty(sql))
                sql = " IsDel = 0";
            return manager.GetDataset(sql);
        }
        public string Insert(TT_TransferTicket obj,out int key)
        {
            string resStr = "";
            
            try
            {
               key =  manager.Insert(obj);
            }
            catch(Exception e)
            {
                key = 0;
                resStr = "添加时出错：" + e.ToString();
            }
            return resStr;
        }

        [DataObjectMethod(DataObjectMethodType.Select)]
        public DataSet SelectByKey(string key)
        {
            try
            {
                if (!string.IsNullOrEmpty(key))
                {
                    return manager.GetDataset(string.Format(" TicketID = '{0}'", key));
                }
            }
            catch
            {
                return null;
            }
            return null;
           
        }

        public bool Delete(string key)
        {
            try
            {
              return   manager.Delete(key)>0?true:false;
            }
            catch
            {
                return false;
            }
        }



    }
}
